package chapter4;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description:  计算最大圆距离
 * Date:2021/4/2
 * ***************************************************************
 */
public class exc4_2 {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		final double R=6371.01;
		
		//读入数据的同时将其转换为弧度
		System.out.println("Enter  point 1 (latitude and"
				+ " longitude)  indegrees: ");
		double x1=Math.toRadians(input.nextDouble());
		double y1=Math.toRadians(input.nextDouble());
		System.out.println("Enter  point 2 (latitude and"
				+ " longitude)  indegrees: ");
		double x2=Math.toRadians(input.nextDouble());
		double y2=Math.toRadians(input.nextDouble());
		System.out.printf("The distance between the two points  is "
				+ "%.11f km.",R*Math.acos(Math.sin(x1)*Math.sin(x2)+Math.cos(x1)*Math.cos(x2)*Math.cos(y1-y2)));
		
	}

}
